package com.belizer.demo.thread;

public class Demo7 {
    private static boolean ready;
    private static int number;

    private static class ReaderThread extends Thread {
        public void run() {
            while (!ready)
                Thread.yield();
            System.out.println(number);
        }
    }

    public static void main(String[] args) {
        int i = 0;
        int j = 100000;
        for (; ; ) {
            new ReaderThread().start();
            number = 42;
            ready = true;

            i++;
            if (i > j) return;
        }
    }
}
